import httpInstance from "@/utils/http";

// 获取用户名与密码
export async function passwordLoginAPI({username, password}){
    try {
      const res = await httpInstance.request({
        url: '/api/user/login',
        method: 'POST',
        data: {
          username,
            password
        }
      })
      return res.data
    } catch (error) {
      console.error('Error fetching user info:', error);
    throw error;
    }
}

export function smsLoginAPI({phone, code}){
    return httpInstance.request({
        url: '/api/user/smslogin',
        method: 'POST',
        data: {
            phone,
            code
        }
    })
}

// 获取用户信息
export function getUserInfoAPI(){
    return request({
        url: '/api/user/info',
        method: 'GET',

        headers: {
            'Authorization': 'Bearer ' + localStorage.getItem('token')
        }
    })
  }